<?php

putenv("DISPLAY=:1");
putenv("XAUTHORITY=/var/www/.Xauthority");

ini_set('display_errors', 1);
error_reporting(E_ALL);

include_once 'Bot.php';
include_once 'Api.php';

$redmineId = $argv[1];
$idTask    = $argv[2];
$playform  = $argv[3];
$skype     = '';
$msg       = '';

if (!$idTask || !$redmineId) {
    exit();
}

$dbus = new Dbus(Dbus::BUS_SESSION, true);
$n = $dbus->createProxy('com.Skype.API', '/com/Skype', 'com.Skype.API');
$n->Invoke('NAME SEND_CHANGE');
$n->Invoke('PROTOCOL 8');
$dbus->registerObject('/com/Skype/Client', 'com.Skype.API.Client', 'Bot');

if ($redmineId != 210) {
    $user = Bot::getInstance()->getUserByIdRedmine($redmineId);
    $msg = 'Таск в редмайне был изменен, юный падаван. http://pm.vs58.net/issues/' .  $idTask;

    var_dump($redmineId);
    var_dump($user);
    if (isset($user['skype']) && $msg  && $playform != $user['playform']) {
        Bot::getInstance()->sendNotifyToSkype($user['skype'], $msg);
    } else {
        echo "NO SENDING 2";
    }
} else {
    echo "NO SENDING 3";
}

exit();